package edu.ynu.e_platform.entities;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import edu.ynu.e_platform.common.entity.LogicEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

/**
 * @author manwen Yang
 */
@Entity
@Getter
@Setter
@Inheritance  //单表继承，继承于该类的其他类都共用一个数据库表，只不过用字段进行区分
@JsonIgnoreProperties(value = {"handler","hibernateLazyInitializer","fieldHandler"})
@Where(clause = "isDeleted = 0")
@DiscriminatorColumn(name = "type")
@EntityListeners(AuditingEntityListener.class)  //监听实体的修改
public abstract class User extends LogicEntity {

    @Column
    protected String username;

    @Column
    protected String password;

    @Column
    protected Integer sex;

    //区别类型字段，设置为不可更新，不可插入
    @Column(updatable = false, insertable = false)
    protected Integer type;

}
